package com.heima.admin.controller.v1;

import com.heima.apis.admin.IAdminClient;
import com.heima.model.admin.dtos.SensitiveDto;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.pojos.WmSensitive;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author HYK
 * @date 2022/10/22
 */
@Slf4j
@RestController
@RequestMapping("/api/v1/sensitive")
public class AdSensitiveController {

    @Autowired
    private IAdminClient iAdminClient;

    /**
     * 列表
     *
     * @param dto dto
     * @return {@link ResponseResult}
     */
    @PostMapping("/list")
    ResponseResult list(@RequestBody SensitiveDto dto) {
        return iAdminClient.list(dto);
    }

    /**
     * 新增敏感词
     */
    @PostMapping("/save")
    public ResponseResult saveSensitive(@RequestBody WmSensitive wmSensitive) {
        return iAdminClient.saveSensitive(wmSensitive);
    }

    /**
     * 修改敏感词
     */
    @PostMapping("/update")
    public ResponseResult updateSensitive(@RequestBody WmSensitive wmSensitive) {
        return iAdminClient.updateSensitive(wmSensitive);
    }

    /**
     * 删除敏感词
     */
    @DeleteMapping("/del/{id}")
    public ResponseResult delSensitive(@PathVariable("id") Integer id) {
        return iAdminClient.deleteSensitive(id);
    }

}
